<?php
require './php/function.php';
require './php/Huluxia.php';
$hlx = new Huluxia($_COOKIE['key']);
$_User = $hlx->checkLogin() ? $hlx->getUserInfo($hlx->getUserIdByKey()) : [];
?>

<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<title><?php echo $title; ?> - 葫芦侠Web - Powered by HuajiMC</title>
	<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
	<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
	<script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>
	<script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
	<link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.css">
	
	<link rel="stylesheet" href="./static/css/app.css">
	<script src="./static/js/app.js"></script>
	<script src="./static/js/clickableTextLink.js"></script>
</head>
<body>
	<nav class="navbar navbar-expand-sm bg-secondary navbar-dark fixed-top">
		<a class="navbar-brand" href="#"><img src="http://huluxia.com/img/icon_logo01.png" height="45"> 葫芦侠Web</a>
		
		<ul class="navbar-nav">
			<li class="nav-item">
				<a class="nav-link" href="./index.php">首页</a>
			</li>
			<li class="nav-item">
				<a class="nav-link" href="#">应用</a>
			</li>
			<li class="nav-item">
				<a class="nav-link" href="#">活动</a>
			</li>
			<li class="nav-item">
				<a class="nav-link" href="#">兑换中心</a>
			</li>
			<li class="nav-item">
				<a class="nav-link" href="#">买定离手</a>
			</li>
		</ul>
		<ul class="navbar-nav ml-auto">
			<li class="nav-item">
				<?php if($_User) { ?>
					<a class="nav-link" href="#">
					<img src="<?php echo $_User['avatar']; ?>" height="45" class="rounded-circle">
					<?php echo $_User['nick']; ?>
					</a>
				<?php } else { ?>
					<button class="btn btn-primary" onclick="javascript:location.href='./login.php?ref_url=<?php echo $_SERVER['REQUEST_URI']; ?>'">登录</button>
					<button class="btn btn-success" onclick="javascript:location.href='./register.php?ref_url=<?php echo $_SERVER['REQUEST_URI']; ?>'">注册</button>
				<?php } ?>
			</li>
		</ul>
	</nav>